<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="content">调岗申请表</block>
			<block slot="right">
				<image @click="showFun" class="nav-right-image" src="@/static/images/nav_opt.png"></image>
			</block>
		</cu-custom>

		<view class="page-content" :style="{height:this.ContentArea+'px',paddingTop:'30rpx'}">
			<view class="page-search">
				<view class="search">
					<view class="search-left">
						<image src="@/static/images/search.png" mode="aspectFit" />
					</view>
					<input class="search-center" type="text" placeholder="搜索名字/工号"
						placeholder-class="search-placeholder" v-model="searchValue">
				</view>
				<view class="filter-btn" @click="onRefresh">
					<image src="@/static/images/filter.png" mode="aspectFit" />
				</view>
			</view>

			<view class="page-content-main">
				<view class="select-box">

					<view style="position: relative;">
            <uni-datetime-picker v-model="createTime" type="line">
              <view class="select">
                <view class="select-value">{{ createTimeShow }}</view>
                <view class="select-icon" v-if="createTime ==''">
                  <image src="@/static/images/downArrow.png" mode="aspectFit" />
                </view>
              </view>
            </uni-datetime-picker>
            <view class="cuIcon-roundclose" v-if="createTime !=''"
                  style="z-index: 9;width: 20px;height: 20px;position: absolute;right: 55rpx;top: 25rpx;color: #FFFFFF;"
                  @click="clearDatetimePicker">
            </view>
					</view>


					<view class="select">

						<my-select range-key="text" value-key="value" dict-code="approval_status"
							v-model="approvalStatus" />

						<view class="select-icon">
							<image src="@/static/images/downArrow.png" mode="aspectFit" />
						</view>
					</view>
				</view>


				<scroll-view class="list" :scroll-y='true' :refresher-enabled="true" :refresher-triggered="refreshing"
					@refresherrefresh="onRefresh" :refresher-background="'#F9F9F9'" @scrolltolower="onEndReached">
					<view class="list-item" v-for="(item,index) in dataList" :key="index">
						<view class="list-item-avatar-box">
							<img class="list-item-avatar" src="@/static/images/avatar.png">
						</view>
						<view class="list-item-sex">
							<text class="list-item-sex-text">男</text>
						</view>
						<view class="list-item-name">
							<text class="list-item-name-text">周恒燊</text>
						</view>
						<view class="list-item-row">
							<text class="list-item-row-text">新工号：CZJ000059</text>
						</view>
						<view class="list-item-row">
							<text class="list-item-row-text">原工号：CZJ000059</text>
						</view>
					</view>


				</scroll-view>
			</view>

		</view>
	</view>
</template>

<script>
	import moment from 'moment';
	export default {
		data() {
			return {
        createTime: moment().format('YYYY-MM-DD'),
				approvalStatus: '',
				searchValue: '',
				dataList: [{},{},{},{},{},{},{},{},{},{},{}],
				isShowFun: false,
				refreshing: true,
				pageSize: 10,
				pageNo: 1,
				total: 0,
				listUrl: '/crm_job_transfer_application/crmJobTransferApplication/list'
			}
		},
		mounted() {
			this.onRefresh()
		},
		computed: {
			createTimeShow: function() {
        return moment(this.createTime).isValid() ? moment(this.createTime).format('MM-DD') : '请选择'
			}
		},
		methods: {
			clearSearch() {
				this.searchValue = ''
			},
			async onRefresh() {
				try {
					this.refreshing = true
					const res = await this.getData(1);
					this.refreshing = false
					this.pageNo = 1
					this.dataList = res?.data?.result?.records
					this.total = res?.data?.result?.total
				} catch (e) {
					this.refreshing = false
					console.log(e)
				}
			},
			async onEndReached() {
				try {
					if (this.pageNo * this.pageSize < this.total) {
						const res = await this.getData(this.pageNo + 1);
						this.pageNo += 1;
						this.dataList = this.dataList.concat(res?.data?.result?.records)
						this.total = res?.data?.result?.total
					}
				} catch (e) {
					console.log(e)
				}
			},
			async getData(pageNo) {
				const params = {
					pageNo: pageNo,
					pageSize: this.pageSize,
					createTime: this.createTime,
					approvalStatus: this.approvalStatus,
					workNo: this.searchValue
				}
				return await this.$http.get(this.listUrl, {
					params: params
				})
			},
			showFun() {
				this.isShowFun = true
			},
			hideFun() {
				this.isShowFun = false
			},
			gotoAdd() {
				uni.navigateTo({
					url: '/pages/oa/crm_job_transfer_application/index'
				})
			},
      clearDatetimePicker() {
        this.createTime = ''
      }
		}
	}
</script>

<style lang="scss" scoped>
	image {
		width: 100%;
		height: 100%;
	}

	.blackList {
		height: 100%;
		overflow: hidden;
	}

	.page-search {
		padding-left: 34rpx;
		margin-bottom: 12rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.search {
		width: 588rpx;
		height: 86rpx;
		background-color: rgba(249, 249, 249, 1);
		border-radius: 60rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding-left: 24rpx;
		padding-right: 24rpx;

		.search-left {
			width: 28rpx;
			height: 28rpx;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.search-center {
			margin-left: 22rpx;
		}

		.search-placeholder {
			font-size: 28rpx;
			font-weight: 400;
			color: #7C7C7C;
		}


	}

	.filter-btn {
		width: 40rpx;
		height: 40rpx;
		margin-right: 42rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.page-content-main {
		// min-height: calc(100% - 12rpx - 86rpx);
		min-height:90%;
		border-radius: 64rpx;
		background-color: #F9F9F9;
		padding: 26rpx 34rpx 0 34rpx
	}

	.select-box {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;

	}

	.select {
		width: 160rpx;
		height: 74rpx;
		border-radius: 60rpx;
		background-color: #4591FE;
		margin-bottom: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		margin-right: 48rpx;
		position: relative;

    .select-value {
      font-size: 28rpx;
      font-weight: 400;
      color: #FFFFFF;
      margin-right: 18rpx;
    }

    .select-icon {
      width: 22rpx;
      height: 22rpx;
      display: flex;
      justify-content: center;
      align-items: center;
      position: absolute;
      right: 20rpx;
      top:25rpx;
    }
	}

	.list {
		max-height: calc(100% - 74rpx - 20rpx);

		::v-deep {
			.uni-scroll-view-content {
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				justify-content: flex-start;

			}
		}

	}

	.list-item {
		background-color: #FFFFFF;
		border-radius: 40rpx;
		width: 322rpx;
		height: 354rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-bottom: 26rpx;
		margin-right: 38rpx;


		.list-item-avatar-box {
			width: 90rpx;
			height: 90rpx;
			border-radius: 90rpx;
			opacity: 1;
			border: 2rpx solid #4591FE;
			display: flex;
			justify-content: center;
			align-items: center;

			margin-bottom: 12rpx;
		}

		.list-item-avatar {
			width: 78rpx;
			height: 78rpx;
		}

		.list-item-sex {
			width: 60rpx;
			height: 42rpx;
			border-radius: 40rpx;
			background-color: rgba(69, 145, 254, 0.33);
			text-align: center;
			line-height: 42rpx;
			margin-bottom: 18rpx;
		}

		.list-item-sex-text {
			font-size: 24rpx;
			color: #4591FE;

		}

		.list-item-name {
			margin-bottom: 20rpx;
		}

		.list-item-name-text {
			font-size: 32rpx;
			font-weight: 500;
			color: #000000;
		}

		.list-item-row {
			margin-bottom: 26rpx;
		}

		.list-item-row-text {
			font-size: 24rpx;
			font-weight: 400;
			color: #000000;
		}
	}

	.list-item:nth-child(odd) {
		margin-right: 0;
	}

	.nav-right-image {
		width: 80rpx;
		height: 80rpx;
		margin-left: 15px;
	}

	.fun-wrap {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(3, 3, 3, 0.28);
		z-index: 10000;
	}

	.fun-box {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		flex-wrap: wrap;
		width: 556rpx;
		height: 656rpx;
		border-top-left-radius: 42rpx;
		border-bottom-left-radius: 42rpx;
		border-bottom-right-radius: 42rpx;
		position: absolute;
		right: 74rpx;
		background-color: #FFFFFF;
	}

	.fun-item {
		width: 185rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-bottom: 44rpx;
	}

	.fun-icon {
		width: 92rpx;
		height: 92rpx;
		margin-bottom: 22rpx;
	}

	.cu-form-group {
		background-color: transparent;
	}

	::v-deep {
		.cu-form-group uni-picker .picker {
			color: #FFFFFF;
		}

		.cu-form-group uni-picker::after {
			opacity: 0;
		}
	}
</style>
